var cc__decorate = __decorate;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var $2BaseUIPopup = require("BaseUIPopup");
var $2UIManager = require("UIManager");
var $2UIHelp = require("UIHelp");
var $2BundleManager = require("BundleManager");
var $2Globe = require("Globe");
var $2GameConfig = require("GameConfig");
var $2levelconfig = require("levelconfig");
var $2gameBefore = require("gameBefore");
var $2UIVMain = require("UIVMain");
var $2GameUser = require("GameUser");
var $2Platformconf = require("Platformconf");
var cc__decorator = cc._decorator;
var ccp_ccclass = cc__decorator.ccclass;
var ccp_property = cc__decorator.property;
var def_UIPLoading = /* */function (_i$default2) {
  function _ctor() {
    var _this114;
    babel_classCallCheck(this, _ctor);
    _this114 = _callSuper(this, _ctor, arguments);
    _this114.boat = null;
    _this114.progressBar = null;
    _this114.loaded = false;
    _this114._startLoad = false;
    _this114._startTime = 0;
    _this114._showUiLevel = false;
    _this114.loadPrefabTime = 0;
    _this114.startLoadPrefab = false;
    return _this114;
  }
  babel_inherits(_ctor, _i$default2);
  return babel_createClass(_ctor, [{
    key: "onShow",
    value: function onShow() {

      if(window['tt']||window['wx']){
        //@ts-ignore
        wx.showShareMenu({
            withShareTicket: true,
            menus: ['shareAppMessage', 'shareTimeline'],
        })
        //@ts-ignore
        wx.onShareAppMessage(function () {
        return {
            title: '我怀疑你过不了第一关?',
            imageUrl: '',
        }
        })
    }


      babel_get(babel_getPrototypeOf(_ctor.prototype), "onShow", this).call(this);
      this.unscheduleAllCallbacks();
      if (!$2GameUser.default.getInstance().IsNewPlayer) {
        $2Platformconf.default.PlatformType === $2Platformconf.ePlatformType.WXGame && cc.Canvas.instance.node.getComponent($2gameBefore.default).BannerShow();
        null != $2UIManager.UIManager.getInstance().getUI($2UIVMain.default) && $2UIManager.UIManager.getInstance().getUI($2UIVMain.default).hideYXQ();
      }

      
    }
  }, {
    key: "onEnable",
    value: function onEnable() {
      babel_get(babel_getPrototypeOf(_ctor.prototype), "onEnable", this).call(this);
      this.reset();
    }
  }, {
    key: "reset",
    value: function reset() {
      this._startLoad = false;
      this._startTime = 0;
      this.boat.x = -18;
      this.progressBar.progress = 0;
    }
  }, {
    key: "showLevelsUi",
    value: function showLevelsUi() {
      var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
      this._startLoad = true;
      this._startTime = 0;
      this.boat.x = -18;
      this.progressBar.progress = 0;
      e || this.scheduleOnce(function () {}, 1);
    }
  }, {
    key: "lateUpdate",
    value: function lateUpdate(e) {
      if (this._startLoad) {
        this._startTime += e;
        if (this._startTime >= 1) {
          if (this._startTime >= 15) {
            this._startLoad = false;
            this.hide();
            $2UIManager.UIManager.getInstance().loadFail();
            $2UIHelp.UIHelp.showTip("资源加载超时，请检查网络");
            this._showUiLevel && console.log("23323424");
          }
        } else {
          var _e63 = .05 * (1 - this.progressBar.progress);
          this.progressBar.progress += _e63;
          this.boat.x = 380 * this.progressBar.progress;
        }
      }
      if (this.startLoadPrefab) {
        this.loadPrefabTime += e;
        if (this.loadPrefabTime >= 10) {
          this.startLoadPrefab = false, this.hide(), $2UIHelp.UIHelp.showTip("资源加载超时，请检查网络"), this._showUiLevel && console.log("23323424");
        }
      }
    }
  }, {
    key: "loadGamePrefab",
    value: function loadGamePrefab(e, t) {
      var _this115 = this;
      var n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
      this._startLoad = true;
      this._startTime = 0;
      this.boat.x = -18;
      this.progressBar.progress = 0;
      this.loadPrefabTime = 0;
      this.startLoadPrefab = true;
      this._showUiLevel = n;
      var o = $2GameConfig.default.getInstance().getConfig($2levelconfig.default).getlevelByName(t).levelsBundleName;
      var i = $2BundleManager.default.getInstance().levelsBundle;
      if (null == (i = "levels" == o ? $2BundleManager.default.getInstance().levelsBundle : $2BundleManager.default.getInstance().levelsBundles[parseInt(o)])) {
        this.loadLevelsBundle(o, function (n) {
          _this115.loadPrefab(n, t, e);
        });
      } else {
        this.loadPrefab(i, t, e);
      }
    }
  }, {
    key: "loadPrefab",
    value: function loadPrefab(e, t, n) {
      var _this116 = this;
      e.load(t + "/prefab/" + t, cc.Prefab, function (e) {
        if (_this116.startLoadPrefab) {
          _this116.startLoadPrefab = false;
          if (e) {
            console.log("------", e), _this116.hide(), $2UIHelp.UIHelp.showTip("资源加载失败"), _this116._showUiLevel && console.log("23323424");
          } else {
            null != n && n.hide();
          }
        }
      });
    }
  }, {
    key: "loadLevelsBundle",
    value: function loadLevelsBundle(e, t) {
      console.log("loadlevelsBundle:");
      $2Globe.default.getInstance().loadBundles(e, function (e) {
        t && t(e);
      });
    }
  }]);
}($2BaseUIPopup.default);
def_UIPLoading.className = "UIPLoading";
cc__decorate([ccp_property({
  type: cc.Node,
  tooltip: "船"
})], def_UIPLoading.prototype, "boat", undefined);
cc__decorate([ccp_property({
  type: cc.ProgressBar,
  tooltip: "进度条"
})], def_UIPLoading.prototype, "progressBar", undefined);
def_UIPLoading = cc__decorate([ccp_ccclass], def_UIPLoading);
exports.default = def_UIPLoading;